#include <iostream>
#include <algorithm>
#include <math.h>
#include <cstring>
using namespace std;
int d[100001],v[100001],a[100001],p[100001];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin >> t;
    while(t--){
        int ans = 0;
        int n,m,l,vv;
        int flag0 = 0,flag1 = 0;
        cin >> n >> m >> l >> vv;
        for(int j = 0; j < n; j++){
            cin >> d[j] >> v[j] >> a[j];
        }
        for(int j = 0; j < m; j++){
            cin >> p[j];
        }
        sort(p,p + m);
        for(int j = 0;j < n; j++){
            if(a[j] >= 0){
                if(p[m - 1] >= d[j]){
                    int s = p[m - 1] - d[j];
                    long long vn = v[j] * v[j] + 2 * a[j] * s;
                    if(vn > vv * vv){
                        ans += 1;
                        flag1 = 1;
                    }
                }
            }else{
                int pw = -1;
                for(int k = 0; k < m; k++){
                    if(p[k] >= d[j]){
                        pw = p[k];
                        break;
                    }
                }
                if(pw != -1){
                    int s = pw - d[j];
                    if(-1 * 2 * a[j] * s <= v[j] * v[j]){
                        long long vn = v[j] * v[j] + 2 * a[j] * s;
                        if(vn >= vv * vv){
                            ans += 1;
                            flag0 = 1;
                        }
                    }
                }
            }
        }
        int w = m;
        if(flag1){
            w -= 1;
        }
        if(flag0){
            w -= 1;
        }
        if(w < 0){
            w == 0;
        }
        cout << ans << " " << w << endl;
    }
    return 0;
}
